﻿package com.fecesaids.greatgame {
	import flash.display.MovieClip;
	public class HUD extends MovieClip{
		private var _curHealth:int;
		private var _maxHealth:int;
		private var _playerName:String;
		private var _avatarMC:MovieClip;
		public function HUD() {
			_curHealth = 100;
			_maxHealth = 100;
			_playerName = "Player";
			dispName();
			dispHealth();
		}
		public function dispName() {
			this.HUD_name.text = _playerName;
		}
		public function dispHealth() {
			this.HUD_healthText.text = "" + _curHealth + "/" + _maxHealth;
			this.HUD_healthBar.scaleX = (Number)(_curHealth)/(Number)(_maxHealth);
		}
		public function modName(modValue:String) {
			_playerName = modValue;
			dispName();
		}
		public function modAvatar(modValue:MovieClip){
			_avatarMC = modValue;
			_avatarMC.x = 0;
			_avatarMC.y = 0;
			HUD_avatar.addChild(_avatarMC); // Definition of a thing that will cause a problem eventually given a lot of time and transitions
		}
		public function modCurHealth(modAmount:int) {
			_curHealth += modAmount;
			if(_curHealth < 0)
				_curHealth = 0;
			if(_curHealth > _maxHealth){
				_curHealth = _maxHealth;
			}
			if(_curHealth == 0){
				//died();
			}
			dispHealth();
		}
		public function modMaxHealth(modAmount:int) {
			_maxHealth += modAmount;
			if(_maxHealth < 0)
				_maxHealth = 0;
			if(_curHealth > _maxHealth){
				_curHealth = _maxHealth;
			}
			if(_curHealth == 0){
				//died();
			}
			dispHealth();
		}
	}
}